import Ashily from "./Ashily.js"
import asynchronous from "./Asynchronous.js"
import Instance from "./Instance.js"
import keyprompt from "./KeyPrompt.js"
import Math from "./Math.js"
import shop_window from "./shop_window.js";
// 商人
const  tradmanClass = {
    update: function () {

        this.DisplayInteractivePrompts()
        

    },

    onLayoutStart() {

         tradmanClass.chooseCurrentTradMan = null // 当前互动物
        tradmanClass.interactiveDis=60

    },



    /**
     * 显示互动提示
     */

    async DisplayInteractivePrompts() {
         
        let interactiveDis = tradmanClass.interactiveDis //互动距离


        for (let tradman of rt.objects.Tradesmen.instances()) {
            let distance = tradman.instVars.DistanceFromPlyer
            // lconsole.log(distance)
            if (distance < interactiveDis) {
                if (tradman.instVars.ActionState == "idle") { // 商人idle状态后 才能 互动


                    keyprompt.showKeyPrompt(tradman, tradman.getImagePointX(1) + 5, tradman.getImagePointY(1) - 25, "E", "talk")
                    
                     tradmanClass.chooseCurrentTradMan = tradman
                    
                    // 关闭互动#############################################################
                    await asynchronous.waitTime(1000)
                
                    keyprompt.RebackKeyPrompt()
                    tradmanClass.chooseCurrentTradMan = null


                }
            }


        }

    },




}

export default  tradmanClass